<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="穷在闹市" />
    <!-- 作者 -->
    <meta name="revised" content="穷在闹市.v3, 2019/05/01" />
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介" />
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
    <title>穷在闹市出品</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="/admin/css/base.css">
    <link rel="stylesheet" type="text/css" href="/admin/css/iconfont.css">
    <script type="text/javascript" src="/admin/framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css">
    <script type="text/javascript" src="/admin/layui/layui.js"></script>
    <!-- 滚动条插件 -->
    <link rel="stylesheet" type="text/css" href="/admin/css/jquery.mCustomScrollbar.css">
    <script src="/admin/framework/jquery-ui-1.10.4.min.js"></script>
    <script src="/admin/framework/jquery.mousewheel.min.js"></script>
    <script src="/admin/framework/jquery.mCustomScrollbar.min.js"></script>
    <script src="/admin/framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

    <style>
        .layui-form-label{
            width: 100px;
        }
        .layui-input-block{
            margin-left: 130px;
        }
        .layui-form{
            margin-right: 30%;
        }
    </style>

</head>

<body>
<div class="cBody">
    <form id="addForm" class="layui-form" action="/agent_add" method="post" enctype="multipart/form-data">
        @csrf
        <div class="layui-form-item">
            <label class="layui-form-label">经纪人名称</label>
            <div class="layui-input-block">
                <input type="text" name="agent_name" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-upload-drag" id="goodsPic">
              <input type="file" name="agent_picture" required lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="agent_tel" required lay-verify="phone|number" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属门店</label>
            <div class="layui-input-block">
                <input type="text" name="agent_store" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">经纪人推荐</label>
            <div class="layui-input-block">
                <input type="text" name="agent_recommend" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属区域</label>
                <div id="cat_ids1" ></div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submitBut">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</div>
</body>
<script>

    $.ajax({
        type:"get",
        url:'/city',
        success:function(data){
            var catData=data;
            for(var i=0;i<catData.length;i++){
                var cat1=catData[i];
                var all1=cat1.all_children;
                if(cat1.all_children.length<=0){
                    delete cat1.all_children;
                }
                for (var j=0;j<all1.length;j++){
                    var cat2=all1[j];
                    var all2=cat2.all_children;
                    if(cat2.all_children.length<=0){
                        delete cat2.all_children;
                    }
                    for (var z=0;z<all2.length;z++){
                        var cat3=all2[z];
                        if(cat3.all_children.length<=0){
                            delete cat3.all_children;
                        }
                    }
                }
            }
            layui.config({
                base : './'
            }).extend({
                selectN: '/admin/layui_extends/selectN',
            }).use(['layer','form','jquery','selectN'],function(){
                $ = layui.jquery;
                var form = layui.form
                    ,selectN = layui.selectN
                //无限级分类-基本配置
                var catIns1 = selectN({
                    ///元素容器【必填】
                    elem: '#cat_ids1'
                    //候选数据【必填】
                    ,data: catData
                    //为真只取最后一个值
                    // ,last: true
                    //事件过滤器，lay-filter名 不设置与选择器相同(去#.)
                    ,filter: ''

                    //input的name 不设置与选择器相同(去#.)
                    ,name: 'cat2'

                    //数据分隔符
                    ,delimiter: ','

                    //添加验证
                    ,verify:'required'

                    //数据的键名
                    ,field:{idName:'id',titleName:'name',childName:'all_children'}

                    //表单区分 form.render(type, filter); 为class="layui-form" 所在元素的 lay-filter="" 的值
                    ,formFilter: null

                });

                //监听重置按钮
                $('form').find(':reset').click(function(){
                    $('form')[0].reset();
                    catIns1.set();//默认值
                    return false;
                });
            });
        }
    });


</script>

</html>
